<div class="section">

	<div class="section-title">Quản lý chức năng</div>
    
    <div class="section-content">
    	
        <form action="" method="post" id="listitem" name="listitem">
        
        	<div class="button right">
                <a class="button add" href="<?php echo $insert?>">Thêm mới</a>
                <a class="button delete" onclick="deleteItem()">Xóa</a>  
            </div>
            <div class="clearer">^&nbsp;</div>
            
            <div class="sitemap treeindex">
                <table class="data-table" cellpadding="0" cellspacing="0">
                <tbody>
                    <tr class="tr-head">
                        <th width="1%"><input class="inputchk" type="checkbox" onclick="$('input[name*=\'delete\']').attr('checked', this.checked);"></th>
                        
                        
                        <th>Mã chức năng</th>
                        <th>Tên chức năng</th>
                        <th>Control</th>                                  
                    </tr>
        
        
        <?php
            foreach($datas as $item)
            {
        ?>
                    <tr>
                        <td class="check-column"><input class="inputchk" type="checkbox" name="delete[<?php echo $item['chucnangid']?>]" value="<?php echo $item['chucnangid']?>" ></td>
                        
                        <td><?php echo $item['machucnang']?></td>
                        <td><?php echo $item['tenchucnang']?></td>
                                               
                        <td class="link-control">
                           	<a class="button edit" href="<?php echo $item['link_edit']?>">Sửa</a>
                            <a class="button action" href="<?php echo $item['link_hanhdong']?>">Hành động</a>
                        </td>
                    </tr>
        <?php
            }
        ?>
                        
                                                    
                </tbody>
                </table>
            </div>
        	<?php echo $pager?>
        
        </form>
        
    </div>
    
</div>
<script language="javascript">
function deleteItem()
{
	var answer = confirm("Bạn có muốn xóa không?")
	if (answer)
	{
		$.post("?route=deliman/chucnang/delete", 
				$("#listitem").serialize(), 
				function(data)
				{
					if(data=="true")
					{
						alert("Xóa thành công");
						window.location.reload();
					}
				}
		);
	}
}
</script>